package com.system.controller;

import com.system.pojo.Department;
import com.system.pojo.EmplAttendance;
import com.system.service.DepartmentService;
import com.system.service.EmplAttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created by 陈文杰 on 2022/6/6 13:44
 */
@Controller
public class TestController {
    @Autowired
    DepartmentService departmentService;
    @RequestMapping("/hello")
    public ModelAndView hello(){
        ModelAndView modelAndView = new ModelAndView();
        List<Department> departments = departmentService.queryDeptAll();
        modelAndView.addObject("departments",departments);
        modelAndView.setViewName("hello");
        return modelAndView;
    }
    @Autowired
    EmplAttendanceService emplAttendanceService;
    @RequestMapping("/hello1")
    public ModelAndView hello1(){
        ModelAndView modelAndView = new ModelAndView();
        List<EmplAttendance> emplAttendances = emplAttendanceService.queryEmplAttendanceByDate("2022-06-07");
        EmplAttendance emplAttendance = emplAttendances.get(0);
        modelAndView.addObject("emplAttendance",emplAttendance);
        modelAndView.setViewName("hello");
        return modelAndView;
    }
}
